using System;
using System.Drawing;
using JAMR.Rendering;
using JAMR.Rendering.Blocks;
using OpenTK;
using Substrate;
using Substrate.Core;
using JAMR.Utils;
using Vector3 = OpenTK.Vector3;

namespace JAMR
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            JAMRSettings settings = JAMRSettings.Load("settings.xml");

            // Window
            OpenTK.Graphics.GraphicsMode mode = OpenTK.Graphics.GraphicsMode.Default;

            Size imageSize = new Size(1024, 1024);
            GameWindow gw = new GameWindow(imageSize.Width, imageSize.Height, mode);

            // Textures
            TextureCache tex = TextureCache.Instance;

            ParseTerrainFile("terrain.png");

            FoliageCache foliage = FoliageCache.Instance;

            foliage.SetFoliage(new Bitmap("foliagecolor.png"));

            // Blocks
            BlockStore blocks = BlockStore.Instance;

            // Render
            NbtWorld world = BetaWorld.Open(settings.MinecraftWorld);

            IChunkManager chunkManager = world.GetChunkManager();
            IBlockManager blockManager = world.GetBlockManager();

            Scene scene = new Scene(chunkManager, blockManager);
            Camera camera = new Camera();

            ChunkRef toRender = chunkManager.GetChunkRef(0, 0);

            camera.SetModel(new Vector3(toRender.X * 16 + 32, 64, toRender.Z * 16 + 32),
                            new Vector3(toRender.X * 16, 64, toRender.Z * 16));
            camera.SetProjection(imageSize, 1024);
            camera.ImageSize = imageSize;

            scene.AddChunk(toRender);
            scene.AddChunk(toRender.GetNorthNeighbor());
            scene.AddChunk(toRender.GetSouthNeighbor());
            scene.AddChunk(toRender.GetWestNeighbor());
            scene.AddChunk(toRender.GetEastNeighbor());

            Bitmap im = scene.RenderScene(camera);

            im.Save("out.png");
        }

        static void ParseTerrainFile(string filename)
        {
            Bitmap t = new Bitmap(filename);
            SolidBlock b;

            TextureCache tex = TextureCache.Instance;
            BlockStore box = BlockStore.Instance;

            // Load textures
            #region TextureLoading
            tex.LoadTexture(t.GetRectangle(0, 0, 16, 16), "grass");
            tex.LoadTexture(t.GetRectangle(16, 0, 16, 16), "stone");
            tex.LoadTexture(t.GetRectangle(32, 0, 16, 16), "dirt");
            tex.LoadTexture(t.GetRectangle(48, 0, 16, 16), "grass_side");
            tex.LoadTexture(t.GetRectangle(64, 0, 16, 16), "tex_4_0");
            tex.LoadTexture(t.GetRectangle(80, 0, 16, 16), "tex_5_0");
            tex.LoadTexture(t.GetRectangle(96, 0, 16, 16), "tex_6_0");
            tex.LoadTexture(t.GetRectangle(112, 0, 16, 16), "tex_7_0");
            tex.LoadTexture(t.GetRectangle(128, 0, 16, 16), "tex_8_0");
            tex.LoadTexture(t.GetRectangle(144, 0, 16, 16), "tex_9_0");
            tex.LoadTexture(t.GetRectangle(160, 0, 16, 16), "tex_10_0");
            tex.LoadTexture(t.GetRectangle(176, 0, 16, 16), "tex_11_0");
            tex.LoadTexture(t.GetRectangle(192, 0, 16, 16), "tex_12_0");
            tex.LoadTexture(t.GetRectangle(208, 0, 16, 16), "tex_13_0");
            tex.LoadTexture(t.GetRectangle(224, 0, 16, 16), "tex_14_0");
            tex.LoadTexture(t.GetRectangle(240, 0, 16, 16), "tex_15_0");
            tex.LoadTexture(t.GetRectangle(0, 16, 16, 16), "cobblestone");
            tex.LoadTexture(t.GetRectangle(16, 16, 16, 16), "tex_1_1");
            tex.LoadTexture(t.GetRectangle(32, 16, 16, 16), "tex_2_1");
            tex.LoadTexture(t.GetRectangle(48, 16, 16, 16), "tex_3_1");
            tex.LoadTexture(t.GetRectangle(64, 16, 16, 16), "tex_4_1");
            tex.LoadTexture(t.GetRectangle(80, 16, 16, 16), "tex_5_1");
            tex.LoadTexture(t.GetRectangle(96, 16, 16, 16), "tex_6_1");
            tex.LoadTexture(t.GetRectangle(112, 16, 16, 16), "tex_7_1");
            tex.LoadTexture(t.GetRectangle(128, 16, 16, 16), "tex_8_1");
            tex.LoadTexture(t.GetRectangle(144, 16, 16, 16), "tex_9_1");
            tex.LoadTexture(t.GetRectangle(160, 16, 16, 16), "tex_10_1");
            tex.LoadTexture(t.GetRectangle(176, 16, 16, 16), "tex_11_1");
            tex.LoadTexture(t.GetRectangle(192, 16, 16, 16), "tex_12_1");
            tex.LoadTexture(t.GetRectangle(208, 16, 16, 16), "tex_13_1");
            tex.LoadTexture(t.GetRectangle(224, 16, 16, 16), "tex_14_1");
            tex.LoadTexture(t.GetRectangle(240, 16, 16, 16), "tex_15_1");
            tex.LoadTexture(t.GetRectangle(0, 32, 16, 16), "tex_0_2");
            tex.LoadTexture(t.GetRectangle(16, 32, 16, 16), "tex_1_2");
            tex.LoadTexture(t.GetRectangle(32, 32, 16, 16), "tex_2_2");
            tex.LoadTexture(t.GetRectangle(48, 32, 16, 16), "tex_3_2");
            tex.LoadTexture(t.GetRectangle(64, 32, 16, 16), "tex_4_2");
            tex.LoadTexture(t.GetRectangle(80, 32, 16, 16), "tex_5_2");
            tex.LoadTexture(t.GetRectangle(96, 32, 16, 16), "tex_6_2");
            tex.LoadTexture(t.GetRectangle(112, 32, 16, 16), "tex_7_2");
            tex.LoadTexture(t.GetRectangle(128, 32, 16, 16), "tex_8_2");
            tex.LoadTexture(t.GetRectangle(144, 32, 16, 16), "tex_9_2");
            tex.LoadTexture(t.GetRectangle(160, 32, 16, 16), "tex_10_2");
            tex.LoadTexture(t.GetRectangle(176, 32, 16, 16), "tex_11_2");
            tex.LoadTexture(t.GetRectangle(192, 32, 16, 16), "tex_12_2");
            tex.LoadTexture(t.GetRectangle(208, 32, 16, 16), "tex_13_2");
            tex.LoadTexture(t.GetRectangle(224, 32, 16, 16), "tex_14_2");
            tex.LoadTexture(t.GetRectangle(240, 32, 16, 16), "tex_15_2");
            tex.LoadTexture(t.GetRectangle(0, 48, 16, 16), "tex_0_3");
            tex.LoadTexture(t.GetRectangle(16, 48, 16, 16), "tex_1_3");
            tex.LoadTexture(t.GetRectangle(32, 48, 16, 16), "tex_2_3");
            tex.LoadTexture(t.GetRectangle(48, 48, 16, 16), "tex_3_3");
            tex.LoadTexture(t.GetRectangle(64, 48, 16, 16), "tex_4_3");
            tex.LoadTexture(t.GetRectangle(80, 48, 16, 16), "tex_5_3");
            tex.LoadTexture(t.GetRectangle(96, 48, 16, 16), "tex_6_3");
            tex.LoadTexture(t.GetRectangle(112, 48, 16, 16), "tex_7_3");
            tex.LoadTexture(t.GetRectangle(128, 48, 16, 16), "tex_8_3");
            tex.LoadTexture(t.GetRectangle(144, 48, 16, 16), "tex_9_3");
            tex.LoadTexture(t.GetRectangle(160, 48, 16, 16), "tex_10_3");
            tex.LoadTexture(t.GetRectangle(176, 48, 16, 16), "tex_11_3");
            tex.LoadTexture(t.GetRectangle(192, 48, 16, 16), "tex_12_3");
            tex.LoadTexture(t.GetRectangle(208, 48, 16, 16), "tex_13_3");
            tex.LoadTexture(t.GetRectangle(224, 48, 16, 16), "tex_14_3");
            tex.LoadTexture(t.GetRectangle(240, 48, 16, 16), "tex_15_3");
            tex.LoadTexture(t.GetRectangle(0, 64, 16, 16), "tex_0_4");
            tex.LoadTexture(t.GetRectangle(16, 64, 16, 16), "tex_1_4");
            tex.LoadTexture(t.GetRectangle(32, 64, 16, 16), "tex_2_4");
            tex.LoadTexture(t.GetRectangle(48, 64, 16, 16), "tex_3_4");
            tex.LoadTexture(t.GetRectangle(64, 64, 16, 16), "snow_side");
            tex.LoadTexture(t.GetRectangle(80, 64, 16, 16), "tex_5_4");
            tex.LoadTexture(t.GetRectangle(96, 64, 16, 16), "tex_6_4");
            tex.LoadTexture(t.GetRectangle(112, 64, 16, 16), "tex_7_4");
            tex.LoadTexture(t.GetRectangle(128, 64, 16, 16), "tex_8_4");
            tex.LoadTexture(t.GetRectangle(144, 64, 16, 16), "tex_9_4");
            tex.LoadTexture(t.GetRectangle(160, 64, 16, 16), "tex_10_4");
            tex.LoadTexture(t.GetRectangle(176, 64, 16, 16), "tex_11_4");
            tex.LoadTexture(t.GetRectangle(192, 64, 16, 16), "tex_12_4");
            tex.LoadTexture(t.GetRectangle(208, 64, 16, 16), "tex_13_4");
            tex.LoadTexture(t.GetRectangle(224, 64, 16, 16), "tex_14_4");
            tex.LoadTexture(t.GetRectangle(240, 64, 16, 16), "tex_15_4");
            tex.LoadTexture(t.GetRectangle(0, 80, 16, 16), "tex_0_5");
            tex.LoadTexture(t.GetRectangle(16, 80, 16, 16), "tex_1_5");
            tex.LoadTexture(t.GetRectangle(32, 80, 16, 16), "tex_2_5");
            tex.LoadTexture(t.GetRectangle(48, 80, 16, 16), "tex_3_5");
            tex.LoadTexture(t.GetRectangle(64, 80, 16, 16), "tex_4_5");
            tex.LoadTexture(t.GetRectangle(80, 80, 16, 16), "tex_5_5");
            tex.LoadTexture(t.GetRectangle(96, 80, 16, 16), "tex_6_5");
            tex.LoadTexture(t.GetRectangle(112, 80, 16, 16), "tex_7_5");
            tex.LoadTexture(t.GetRectangle(128, 80, 16, 16), "tex_8_5");
            tex.LoadTexture(t.GetRectangle(144, 80, 16, 16), "tex_9_5");
            tex.LoadTexture(t.GetRectangle(160, 80, 16, 16), "tex_10_5");
            tex.LoadTexture(t.GetRectangle(176, 80, 16, 16), "tex_11_5");
            tex.LoadTexture(t.GetRectangle(192, 80, 16, 16), "tex_12_5");
            tex.LoadTexture(t.GetRectangle(208, 80, 16, 16), "tex_13_5");
            tex.LoadTexture(t.GetRectangle(224, 80, 16, 16), "tex_14_5");
            tex.LoadTexture(t.GetRectangle(240, 80, 16, 16), "tex_15_5");
            tex.LoadTexture(t.GetRectangle(0, 96, 16, 16), "tex_0_6");
            tex.LoadTexture(t.GetRectangle(16, 96, 16, 16), "tex_1_6");
            tex.LoadTexture(t.GetRectangle(32, 96, 16, 16), "tex_2_6");
            tex.LoadTexture(t.GetRectangle(48, 96, 16, 16), "tex_3_6");
            tex.LoadTexture(t.GetRectangle(64, 96, 16, 16), "tex_4_6");
            tex.LoadTexture(t.GetRectangle(80, 96, 16, 16), "tex_5_6");
            tex.LoadTexture(t.GetRectangle(96, 96, 16, 16), "tex_6_6");
            tex.LoadTexture(t.GetRectangle(112, 96, 16, 16), "tex_7_6");
            tex.LoadTexture(t.GetRectangle(128, 96, 16, 16), "tex_8_6");
            tex.LoadTexture(t.GetRectangle(144, 96, 16, 16), "tex_9_6");
            tex.LoadTexture(t.GetRectangle(160, 96, 16, 16), "tex_10_6");
            tex.LoadTexture(t.GetRectangle(176, 96, 16, 16), "tex_11_6");
            tex.LoadTexture(t.GetRectangle(192, 96, 16, 16), "tex_12_6");
            tex.LoadTexture(t.GetRectangle(208, 96, 16, 16), "tex_13_6");
            tex.LoadTexture(t.GetRectangle(224, 96, 16, 16), "tex_14_6");
            tex.LoadTexture(t.GetRectangle(240, 96, 16, 16), "tex_15_6");
            tex.LoadTexture(t.GetRectangle(0, 112, 16, 16), "tex_0_7");
            tex.LoadTexture(t.GetRectangle(16, 112, 16, 16), "tex_1_7");
            tex.LoadTexture(t.GetRectangle(32, 112, 16, 16), "tex_2_7");
            tex.LoadTexture(t.GetRectangle(48, 112, 16, 16), "tex_3_7");
            tex.LoadTexture(t.GetRectangle(64, 112, 16, 16), "tex_4_7");
            tex.LoadTexture(t.GetRectangle(80, 112, 16, 16), "tex_5_7");
            tex.LoadTexture(t.GetRectangle(96, 112, 16, 16), "tex_6_7");
            tex.LoadTexture(t.GetRectangle(112, 112, 16, 16), "tex_7_7");
            tex.LoadTexture(t.GetRectangle(128, 112, 16, 16), "tex_8_7");
            tex.LoadTexture(t.GetRectangle(144, 112, 16, 16), "tex_9_7");
            tex.LoadTexture(t.GetRectangle(160, 112, 16, 16), "tex_10_7");
            tex.LoadTexture(t.GetRectangle(176, 112, 16, 16), "tex_11_7");
            tex.LoadTexture(t.GetRectangle(192, 112, 16, 16), "tex_12_7");
            tex.LoadTexture(t.GetRectangle(208, 112, 16, 16), "tex_13_7");
            tex.LoadTexture(t.GetRectangle(224, 112, 16, 16), "tex_14_7");
            tex.LoadTexture(t.GetRectangle(240, 112, 16, 16), "tex_15_7");
            tex.LoadTexture(t.GetRectangle(0, 128, 16, 16), "tex_0_8");
            tex.LoadTexture(t.GetRectangle(16, 128, 16, 16), "tex_1_8");
            tex.LoadTexture(t.GetRectangle(32, 128, 16, 16), "tex_2_8");
            tex.LoadTexture(t.GetRectangle(48, 128, 16, 16), "tex_3_8");
            tex.LoadTexture(t.GetRectangle(64, 128, 16, 16), "tex_4_8");
            tex.LoadTexture(t.GetRectangle(80, 128, 16, 16), "tex_5_8");
            tex.LoadTexture(t.GetRectangle(96, 128, 16, 16), "tex_6_8");
            tex.LoadTexture(t.GetRectangle(112, 128, 16, 16), "tex_7_8");
            tex.LoadTexture(t.GetRectangle(128, 128, 16, 16), "tex_8_8");
            tex.LoadTexture(t.GetRectangle(144, 128, 16, 16), "tex_9_8");
            tex.LoadTexture(t.GetRectangle(160, 128, 16, 16), "tex_10_8");
            tex.LoadTexture(t.GetRectangle(176, 128, 16, 16), "tex_11_8");
            tex.LoadTexture(t.GetRectangle(192, 128, 16, 16), "tex_12_8");
            tex.LoadTexture(t.GetRectangle(208, 128, 16, 16), "tex_13_8");
            tex.LoadTexture(t.GetRectangle(224, 128, 16, 16), "tex_14_8");
            tex.LoadTexture(t.GetRectangle(240, 128, 16, 16), "tex_15_8");
            tex.LoadTexture(t.GetRectangle(0, 144, 16, 16), "tex_0_9");
            tex.LoadTexture(t.GetRectangle(16, 144, 16, 16), "tex_1_9");
            tex.LoadTexture(t.GetRectangle(32, 144, 16, 16), "tex_2_9");
            tex.LoadTexture(t.GetRectangle(48, 144, 16, 16), "tex_3_9");
            tex.LoadTexture(t.GetRectangle(64, 144, 16, 16), "tex_4_9");
            tex.LoadTexture(t.GetRectangle(80, 144, 16, 16), "tex_5_9");
            tex.LoadTexture(t.GetRectangle(96, 144, 16, 16), "tex_6_9");
            tex.LoadTexture(t.GetRectangle(112, 144, 16, 16), "tex_7_9");
            tex.LoadTexture(t.GetRectangle(128, 144, 16, 16), "tex_8_9");
            tex.LoadTexture(t.GetRectangle(144, 144, 16, 16), "tex_9_9");
            tex.LoadTexture(t.GetRectangle(160, 144, 16, 16), "tex_10_9");
            tex.LoadTexture(t.GetRectangle(176, 144, 16, 16), "tex_11_9");
            tex.LoadTexture(t.GetRectangle(192, 144, 16, 16), "tex_12_9");
            tex.LoadTexture(t.GetRectangle(208, 144, 16, 16), "tex_13_9");
            tex.LoadTexture(t.GetRectangle(224, 144, 16, 16), "tex_14_9");
            tex.LoadTexture(t.GetRectangle(240, 144, 16, 16), "tex_15_9");
            tex.LoadTexture(t.GetRectangle(0, 160, 16, 16), "tex_0_10");
            tex.LoadTexture(t.GetRectangle(16, 160, 16, 16), "tex_1_10");
            tex.LoadTexture(t.GetRectangle(32, 160, 16, 16), "tex_2_10");
            tex.LoadTexture(t.GetRectangle(48, 160, 16, 16), "tex_3_10");
            tex.LoadTexture(t.GetRectangle(64, 160, 16, 16), "tex_4_10");
            tex.LoadTexture(t.GetRectangle(80, 160, 16, 16), "tex_5_10");
            tex.LoadTexture(t.GetRectangle(96, 160, 16, 16), "tex_6_10");
            tex.LoadTexture(t.GetRectangle(112, 160, 16, 16), "tex_7_10");
            tex.LoadTexture(t.GetRectangle(128, 160, 16, 16), "tex_8_10");
            tex.LoadTexture(t.GetRectangle(144, 160, 16, 16), "tex_9_10");
            tex.LoadTexture(t.GetRectangle(160, 160, 16, 16), "tex_10_10");
            tex.LoadTexture(t.GetRectangle(176, 160, 16, 16), "tex_11_10");
            tex.LoadTexture(t.GetRectangle(192, 160, 16, 16), "tex_12_10");
            tex.LoadTexture(t.GetRectangle(208, 160, 16, 16), "tex_13_10");
            tex.LoadTexture(t.GetRectangle(224, 160, 16, 16), "tex_14_10");
            tex.LoadTexture(t.GetRectangle(240, 160, 16, 16), "tex_15_10");
            tex.LoadTexture(t.GetRectangle(0, 176, 16, 16), "tex_0_11");
            tex.LoadTexture(t.GetRectangle(16, 176, 16, 16), "tex_1_11");
            tex.LoadTexture(t.GetRectangle(32, 176, 16, 16), "tex_2_11");
            tex.LoadTexture(t.GetRectangle(48, 176, 16, 16), "tex_3_11");
            tex.LoadTexture(t.GetRectangle(64, 176, 16, 16), "tex_4_11");
            tex.LoadTexture(t.GetRectangle(80, 176, 16, 16), "tex_5_11");
            tex.LoadTexture(t.GetRectangle(96, 176, 16, 16), "tex_6_11");
            tex.LoadTexture(t.GetRectangle(112, 176, 16, 16), "tex_7_11");
            tex.LoadTexture(t.GetRectangle(128, 176, 16, 16), "tex_8_11");
            tex.LoadTexture(t.GetRectangle(144, 176, 16, 16), "tex_9_11");
            tex.LoadTexture(t.GetRectangle(160, 176, 16, 16), "tex_10_11");
            tex.LoadTexture(t.GetRectangle(176, 176, 16, 16), "tex_11_11");
            tex.LoadTexture(t.GetRectangle(192, 176, 16, 16), "tex_12_11");
            tex.LoadTexture(t.GetRectangle(208, 176, 16, 16), "tex_13_11");
            tex.LoadTexture(t.GetRectangle(224, 176, 16, 16), "tex_14_11");
            tex.LoadTexture(t.GetRectangle(240, 176, 16, 16), "tex_15_11");
            tex.LoadTexture(t.GetRectangle(0, 192, 16, 16), "tex_0_12");
            tex.LoadTexture(t.GetRectangle(16, 192, 16, 16), "tex_1_12");
            tex.LoadTexture(t.GetRectangle(32, 192, 16, 16), "tex_2_12");
            tex.LoadTexture(t.GetRectangle(48, 192, 16, 16), "tex_3_12");
            tex.LoadTexture(t.GetRectangle(64, 192, 16, 16), "tex_4_12");
            tex.LoadTexture(t.GetRectangle(80, 192, 16, 16), "tex_5_12");
            tex.LoadTexture(t.GetRectangle(96, 192, 16, 16), "tex_6_12");
            tex.LoadTexture(t.GetRectangle(112, 192, 16, 16), "tex_7_12");
            tex.LoadTexture(t.GetRectangle(128, 192, 16, 16), "tex_8_12");
            tex.LoadTexture(t.GetRectangle(144, 192, 16, 16), "tex_9_12");
            tex.LoadTexture(t.GetRectangle(160, 192, 16, 16), "tex_10_12");
            tex.LoadTexture(t.GetRectangle(176, 192, 16, 16), "tex_11_12");
            tex.LoadTexture(t.GetRectangle(192, 192, 16, 16), "tex_12_12");
            tex.LoadTexture(t.GetRectangle(208, 192, 16, 16), "tex_13_12");
            tex.LoadTexture(t.GetRectangle(224, 192, 16, 16), "tex_14_12");
            tex.LoadTexture(t.GetRectangle(240, 192, 16, 16), "tex_15_12");
            tex.LoadTexture(t.GetRectangle(0, 208, 16, 16), "tex_0_13");
            tex.LoadTexture(t.GetRectangle(16, 208, 16, 16), "tex_1_13");
            tex.LoadTexture(t.GetRectangle(32, 208, 16, 16), "tex_2_13");
            tex.LoadTexture(t.GetRectangle(48, 208, 16, 16), "tex_3_13");
            tex.LoadTexture(t.GetRectangle(64, 208, 16, 16), "tex_4_13");
            tex.LoadTexture(t.GetRectangle(80, 208, 16, 16), "tex_5_13");
            tex.LoadTexture(t.GetRectangle(96, 208, 16, 16), "tex_6_13");
            tex.LoadTexture(t.GetRectangle(112, 208, 16, 16), "tex_7_13");
            tex.LoadTexture(t.GetRectangle(128, 208, 16, 16), "tex_8_13");
            tex.LoadTexture(t.GetRectangle(144, 208, 16, 16), "tex_9_13");
            tex.LoadTexture(t.GetRectangle(160, 208, 16, 16), "tex_10_13");
            tex.LoadTexture(t.GetRectangle(176, 208, 16, 16), "tex_11_13");
            tex.LoadTexture(t.GetRectangle(192, 208, 16, 16), "tex_12_13");
            tex.LoadTexture(t.GetRectangle(208, 208, 16, 16), "tex_13_13");
            tex.LoadTexture(t.GetRectangle(224, 208, 16, 16), "tex_14_13");
            tex.LoadTexture(t.GetRectangle(240, 208, 16, 16), "tex_15_13");
            tex.LoadTexture(t.GetRectangle(0, 224, 16, 16), "tex_0_14");
            tex.LoadTexture(t.GetRectangle(16, 224, 16, 16), "tex_1_14");
            tex.LoadTexture(t.GetRectangle(32, 224, 16, 16), "tex_2_14");
            tex.LoadTexture(t.GetRectangle(48, 224, 16, 16), "tex_3_14");
            tex.LoadTexture(t.GetRectangle(64, 224, 16, 16), "tex_4_14");
            tex.LoadTexture(t.GetRectangle(80, 224, 16, 16), "tex_5_14");
            tex.LoadTexture(t.GetRectangle(96, 224, 16, 16), "tex_6_14");
            tex.LoadTexture(t.GetRectangle(112, 224, 16, 16), "tex_7_14");
            tex.LoadTexture(t.GetRectangle(128, 224, 16, 16), "tex_8_14");
            tex.LoadTexture(t.GetRectangle(144, 224, 16, 16), "tex_9_14");
            tex.LoadTexture(t.GetRectangle(160, 224, 16, 16), "tex_10_14");
            tex.LoadTexture(t.GetRectangle(176, 224, 16, 16), "tex_11_14");
            tex.LoadTexture(t.GetRectangle(192, 224, 16, 16), "tex_12_14");
            tex.LoadTexture(t.GetRectangle(208, 224, 16, 16), "tex_13_14");
            tex.LoadTexture(t.GetRectangle(224, 224, 16, 16), "tex_14_14");
            tex.LoadTexture(t.GetRectangle(240, 224, 16, 16), "tex_15_14");
            tex.LoadTexture(t.GetRectangle(0, 240, 16, 16), "tex_0_15");
            tex.LoadTexture(t.GetRectangle(16, 240, 16, 16), "tex_1_15");
            tex.LoadTexture(t.GetRectangle(32, 240, 16, 16), "tex_2_15");
            tex.LoadTexture(t.GetRectangle(48, 240, 16, 16), "tex_3_15");
            tex.LoadTexture(t.GetRectangle(64, 240, 16, 16), "tex_4_15");
            tex.LoadTexture(t.GetRectangle(80, 240, 16, 16), "tex_5_15");
            tex.LoadTexture(t.GetRectangle(96, 240, 16, 16), "tex_6_15");
            tex.LoadTexture(t.GetRectangle(112, 240, 16, 16), "tex_7_15");
            tex.LoadTexture(t.GetRectangle(128, 240, 16, 16), "tex_8_15");
            tex.LoadTexture(t.GetRectangle(144, 240, 16, 16), "tex_9_15");
            tex.LoadTexture(t.GetRectangle(160, 240, 16, 16), "tex_10_15");
            tex.LoadTexture(t.GetRectangle(176, 240, 16, 16), "tex_11_15");
            tex.LoadTexture(t.GetRectangle(192, 240, 16, 16), "tex_12_15");
            tex.LoadTexture(t.GetRectangle(208, 240, 16, 16), "tex_13_15");
            tex.LoadTexture(t.GetRectangle(224, 240, 16, 16), "tex_14_15");
            tex.LoadTexture(t.GetRectangle(240, 240, 16, 16), "tex_15_15");
            #endregion

            // Stone
            b = new SolidBlock();
            b.Textures.SetAll("stone");

            box.SetById(BlockInfo.Stone.ID, b);

            // Dirt
            b = new SolidBlock();
            b.Textures.SetAll("dirt");

            box.SetById(BlockInfo.Dirt.ID, b);

            // Grass
            box.SetById(BlockInfo.Grass.ID, new Grass("grass_side", "snow_side", "grass", "dirt"));

            // Cobblestone
            b = new SolidBlock();
            b.Textures.SetAll("cobblestone");

            box.SetById(BlockInfo.Cobblestone.ID, b);
        }
    }
}